<?php
session_start();
include '../connect.php';
include '../functions.inc';
include 'verifform.php';

$sql = ("SELECT user_id FROM $table_name WHERE user_name='".mysql_real_escape_string($_SESSION['logname'])."'");
$result = mysql_query($sql,$db);
$user_id = mysql_fetch_array($result);

$sql = ("DELETE FROM education WHERE user_id='".mysql_real_escape_string($user_id[0])."'");
mysql_query($sql,$db);

	for ( $i=1; $i < 5; $i++ )
	{ 
		if ( $_POST["org_$i"] != "" )
		{
			$dtstart = $_POST["dtstart_$i"];
			$dtend = $_POST["dtend_$i"];
			
			$sql = ("INSERT INTO education VALUES('', '".mysql_real_escape_string($user_id[0])."', 
			'".mysql_real_escape_string($dtstart)."', 
			'".mysql_real_escape_string($dtend)."', 
			'".mysql_real_escape_string($_POST["org_$i"])."')");
			
			updateDateUser($_SESSION['logname'],$table_name);
			mysql_query($sql) or die('coucou'.mysql_error());
			
		}
	}

?>